﻿/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.Collections.Generic;
using System.Text;

namespace PickGold.Util.WordSpliter
{

	[Serializable]
	public class Keyword : IKeyword, IComparable<Keyword>
	{
		/// <summary>
		/// Word
		/// </summary>
		public string Word;

		/// <summary>
		/// Part of speech
		/// </summary>
		public KeywordFlags Flags;

		/// <summary>
		/// Frequency for this word
		/// </summary>
		public double Frequency;

		string IKeyword.Word
		{
			get
			{
				return this.Word;
			}
			set
			{
				this.Word = value;
			}
		}

		KeywordFlags IKeyword.Flags
		{
			get
			{
				return this.Flags;
			}
			set
			{
				this.Flags = value;
			}
		}

		double IKeyword.Frequency
		{
			get
			{
				return this.Frequency;
			}
			set
			{
				this.Frequency = value;
			}
		}

		public Keyword()
		{

		}

		public Keyword(string word, KeywordFlags flags, double frequency)
		{
			this.Word = word;
			this.Flags = flags;
			this.Frequency = frequency;
		}

		public override string ToString()
		{
			return Word;
		}

		public int CompareTo(IKeyword other)
		{
			return this.Word.CompareTo(other.Word);
		}

		public int CompareTo(Keyword other)
		{
			return this.Word.CompareTo(other.Word);
		}
	}

	[Serializable]
	public struct SKeyword : IKeyword, IComparable<SKeyword>
	{
		/// <summary>
		/// Word
		/// </summary>
		public String Word;

		/// <summary>
		/// Part of speech
		/// </summary>
		public KeywordFlags Flags;

		/// <summary>
		/// Frequency for this word
		/// </summary>
		public double Frequency;

		string IKeyword.Word
		{
			get
			{
				return this.Word;
			}
			set
			{
				this.Word = value;
			}
		}

		KeywordFlags IKeyword.Flags
		{
			get
			{
				return this.Flags;
			}
			set
			{
				this.Flags = value;
			}
		}

		double IKeyword.Frequency
		{
			get
			{
				return this.Frequency;
			}
			set
			{
				this.Frequency = value;
			}
		}

		public SKeyword(Keyword keyword)
		{
			this.Word = keyword.Word;
			this.Flags = keyword.Flags;
			this.Frequency = keyword.Frequency;
		}

		public SKeyword(string word, KeywordFlags flags, double frequency)
		{
			this.Word = word;
			this.Flags = flags;
			this.Frequency = frequency;
		}

		public override string ToString()
		{
			return Word;
		}

		public int CompareTo(IKeyword other)
		{
			return this.Word.CompareTo(other.Word);
		}

		public int CompareTo(SKeyword other)
		{
			return this.Word.CompareTo(other.Word);
		}
	}

	public interface IKeyword : IComparable<IKeyword>
	{
		/// <summary>
		/// Word
		/// </summary>
		String Word { set; get; }

		/// <summary>
		/// Part of speech
		/// </summary>
		KeywordFlags Flags { set; get; }

		/// <summary>
		/// Frequency for this word
		/// </summary>
		double Frequency { set; get; }
	}
}
